home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 May: Tool Chest / Dev.CD May 97 TC.toast / Sample Code / Snippets / Toolbox / Sys7 popUpCDEF / SimplePopupCDEF.c next >
Encoding:
C/C++ Source or Header  |  1995-02-10  |  21.2 KB  |  584 lines  |  [TEXT/MPS ]

  1. /* A small sample of how to use the popupCDEF under System 7 */
  2. /* Pretty straighforward */
  3. /* Look at the Rez file to see how to set up the */
  4. /* different types of PopUps shown here. */
  5. /* One other thing of importance..... */
  6.  
  7. /* A menu created with the popupCDEF is NOT always included in the */
  8. /* menu list!  The CDEF can (and will) remove it from the menu list  */
  9. /* when it needs to.  That means that you CANNOT */
  10. /* call GetMenuHandle(...) to get a handle to a popupCDEF menu handle. */
  11. /* Look at the fuction here called 
  12.     GetPopUpMenuHandle
  13.    to see how to do this the correct way. */
  14. /* Of course, Copyright 1991-1992, Apple Computer Inc. */
  15. /* C.K. Haun */
  16. /* Apple Developer Techniocal Support */
  17. #include "SimplePopupCDEF.h"
  18.  
  19.  
  20. typedef struct popupPrivateData {
  21. MenuHandle mHandle; /* the popup menu handle */
  22. short mID;          /* the popup menu ID */
  23. /* after these two public fields is the mPrivate private data, */
  24. /* which may be any old size and should not be messed with */
  25. }popupPrivateData;
  26. typedef popupPrivateData *popupPrivateDataPtr,**popupPrivateDataHdl;
  27.  
  28.  
  29.  
  30. /* prototypes */
  31.  
  32. void InitalizeApp(void);
  33. void DoDiskEvents(long dinfo);                              /* hi word is error code, lo word is drive number */
  34. void DrawMain(WindowPtr drawIt);
  35. Boolean DoSelected(long val);
  36. void SizeMain(WindowPtr theWindow);
  37. void InitAEStuff(void);
  38. void DoHighLevel(EventRecord *AERecord);
  39. void DoDaCall(MenuHandle themenu, long theit);
  40. void DoDocumentClick(WindowPtr theWindow);
  41.  
  42. pascal OSErr AEOpenHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
  43. pascal OSErr AEOpenDocHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
  44. pascal OSErr AEPrintHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
  45. pascal OSErr AEQuitHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
  46.  
  47. void SampleHelpDialog(void);
  48.  
  49. WindowPtr AddNewWindow(short theID);
  50. MenuHandle GetPopUpMenuHandle(ControlHandle thisControl);
  51. void NilProc(void);
  52. /* one external */
  53. extern void _DataInit();                                    /* this is the C initialization code */
  54.  
  55. /* globals */
  56. Boolean gQuit, gInBackground;
  57. unsigned long gMySleep;
  58. ProcessSerialNumber gOurSN;
  59. short gHelpItem;
  60.  
  61. #ifdef powerc
  62.    QDGlobals    qd;
  63. #endif
  64.  
  65. #pragma segment Main
  66. main()
  67. {
  68.     EventRecord myEventRecord;
  69.     WindowPtr twindow;
  70.     short fHit;
  71.     windowCHandle tempWCH;
  72.  
  73.     UnloadSeg((Ptr)_DataInit);                              /* throw out setup code */
  74.     InitalizeApp();
  75.     UnloadSeg((Ptr)InitalizeApp);                           /* get rid of my initialization code */
  76.     do {
  77.         
  78.          WaitNextEvent(everyEvent, &myEventRecord, gMySleep, nil);
  79.         switch (myEventRecord.what) {
  80.             case nullEvent:
  81.                 /* no nul processing in this sample */
  82.                 break;
  83.             case updateEvt:
  84.             /* always check to see if it's my window */
  85.             /* this may not seem necessary under 7.0, where it's unlikely or impossible for */
  86.             /* a DA to be in your layer, but there are others  */
  87.             /* who can stick themselves into your window list, */
  88.             /* BalloonWriter comes quickly to mind */
  89.                 tempWCH = (windowCHandle)GetWRefCon((WindowPtr)myEventRecord.message);
  90.                 (ProcPtr)((*tempWCH)->drawMe)((WindowPtr)myEventRecord.message);
  91.                 break;
  92.             case mouseDown:
  93.                 /* first see where the hit was */
  94.                 fHit = FindWindow(myEventRecord.where, &twindow);
  95.                 switch (fHit) {
  96.                 Rect limitRect;
  97.                 Str255 tempString;    
  98.                 long back;
  99.                     case inDesk:                            /* if they hit in desk, then the process manager */
  100.                         break;                              /* will switch us out, we don't need to do anything */
  101.                     case inMenuBar:
  102.                         DoSelected(MenuSelect(myEventRecord.where));
  103.                         break;
  104.                         
  105.                     case inSysWindow:
  106.                         /* pass to the system */
  107.                         SystemClick(&myEventRecord, twindow);
  108.                         break;
  109.                     case inContent:
  110.                         /* Handle content and control clicks here */
  111.                 if (FrontWindow()) {           /* don't do this unless we have a window open, silly */
  112.                             windowCHandle clicker;
  113.                             clicker = (windowCHandle)GetWRefCon(twindow);
  114.                             /* jump to the content function stored for this window */
  115.                             HLock((Handle)clicker);     /* lock it down so things don't get stupid */
  116.                             (ProcPtr)((*clicker)->clickMe)(twindow);
  117.                             HUnlock((Handle)clicker);       /* all done */
  118.                         }
  119.  
  120.                         break;
  121.                     case inDrag:
  122.                             DragWindow(twindow, myEventRecord.where, &qd.screenBits.bounds);
  123.                         break;
  124.                     case inGrow:
  125.                         /* Call GrowWindow here if you have a grow box */
  126.                      SetPort(twindow);
  127.                         limitRect = qd.screenBits.bounds;
  128.                         limitRect.top = kMinHeight;
  129.                         GetWTitle(twindow, tempString);
  130.                         /* I'm not letting the user shrink the window so */
  131.                         /* small that the title is truncated */
  132.                         limitRect.left = StringWidth(tempString) + 120;
  133.                         back = GrowWindow(twindow,myEventRecord.where, &limitRect);
  134.                         
  135.                         if (back) {windowCHandle tempWCH = (windowCHandle)GetWRefCon(twindow);
  136.                             Rect sizeRect = ((WindowPtr)twindow)->portRect;                            
  137.                             InvalRect(&sizeRect);
  138.                             sizeRect.top = sizeRect.bottom - 16;
  139.                             sizeRect.left = sizeRect.right - 16;
  140.                             EraseRect(&sizeRect);
  141.                             InvalRect(&sizeRect);                            
  142.                             SizeWindow(twindow, back & 0xffff, back >> 16, true);
  143.                             (ProcPtr)((*tempWCH)->sizeMe)(twindow);                            
  144.                         }
  145.                        
  146.                         InvalRect(&twindow->portRect);
  147.  
  148.                         break;
  149.                     case inGoAway:
  150.                         /* Click in Close box */
  151.                 if (TrackGoAway(twindow, myEventRecord.where))
  152.                     (ProcPtr)((*(windowCHandle)((WindowPeek)twindow)->refCon)->closeMe)(twindow);
  153.  
  154.                         break;
  155.                                         case inZoomIn:
  156.                     case inZoomOut:
  157.                     if (TrackBox(twindow, myEventRecord.where, fHit)) {windowCHandle tempWCH = (windowCHandle)GetWRefCon(twindow);
  158.                             SetPort(twindow);                            
  159.                             InvalRect(&twindow->portRect);                        
  160.                             
  161.                             ZoomWindow(twindow, fHit, true);
  162.                         (ProcPtr)((*tempWCH)->sizeMe)(twindow);
  163.                         }
  164.     
  165.                         
  166.                 }
  167.             case mouseUp:
  168.                 /* don't care */
  169.                 break;
  170.                 /* same action for key or auto key */
  171.             case keyDown:
  172.             case autoKey:
  173.                 if (myEventRecord.modifiers & cmdKey)
  174.                     DoSelected(MenuKey(myEventRecord.message & charCodeMask));
  175.                 break;
  176.             case keyUp:
  177.                 /* don't care */
  178.                 break;
  179.             case diskEvt:
  180.                 /* I don't do anything special for disk events, this just passes them */
  181.                 /* to a function that checks for an error on the mount */
  182.                 DoDiskEvents(myEventRecord.message);
  183.                 break;
  184.             case activateEvt:
  185.                 if (myEventRecord.modifiers & activeFlag){
  186.                 tempWCH = (windowCHandle)GetWRefCon((WindowPtr)myEventRecord.message);
  187.                 (ProcPtr)((*tempWCH)->drawMe)((WindowPtr)myEventRecord.message);
  188.                     }
  189.                 break;
  190.             case networkEvt:
  191.                 /* don't care */
  192.                 break;
  193.             case driverEvt:
  194.                 /* don't care */
  195.                 break;
  196.             case app4Evt:
  197.                 switch ((myEventRecord.message >> 24) & 0x0FF) {     /* high byte of message */
  198.                     case suspendResumeMessage:              /* suspend/resume is also an activate/deactivate */
  199.                         gInBackground = (myEventRecord.message & kResumeMask) == 0;
  200.                         if(!gInBackground)InitCursor();
  201.                         break;
  202.                 }
  203.                 break;
  204.             default:
  205.                 break;
  206.                 /* This dispatches high level events (AppleEvents, for example) */
  207.                 /* to our dispatch routine.  This is NEW in the event loop for */
  208.                 /* System 7 */
  209.             case kHighLevelEvent:
  210.                 DoHighLevel(&myEventRecord);
  211.                 break;
  212.                 
  213.         }
  214.     }
  215.             while (gQuit != true);
  216.     
  217. }
  218.  
  219. /* DoDaCall opens the requested DA.  It's here as a seperate routine if you'd */
  220. /* like to perform some action or just know when a DA is opened in your */
  221. /* layer.  Can be handy to track memory problems when a DA is opened */
  222. /* with an Option-open */
  223. void DoDaCall(MenuHandle themenu, long theit)
  224. {
  225.     long qq;
  226.     char DAname[255];
  227.     GetMenuItemText(themenu, theit, &DAname);
  228.     qq = OpenDeskAcc(DAname);
  229. }
  230.  
  231. /* end DoDaCall */
  232.  
  233. /* DoDiskEvents just checks the error code from the disk mount, */
  234. /* and puts up the 'Format' dialog (through DIBadMount) if need be */
  235. /* You can do much more here if you care about what disks are */
  236. /* in the drive */
  237. void DoDiskEvents(long dinfo)                               /* hi word is error code, lo word is drive number */
  238. {
  239.     short hival, loval, tommy;
  240.     Point fredpoint =  {
  241.         40, 40
  242.     };
  243.     hival = HiWord(dinfo);
  244.     loval = LoWord(dinfo);
  245.     if (hival != noErr)                                     /* something happened */ {
  246.         tommy = DIBadMount(fredpoint, dinfo);
  247.     }
  248. }
  249.  
  250. /* draws my window.  Pretty simple */
  251. void DrawMain(WindowPtr drawIt)
  252. {
  253.     RgnHandle tempRgn;
  254.     Rect scratchRect;
  255.     BeginUpdate(drawIt);
  256.     SetPort(drawIt);
  257.     EraseRect(&drawIt->portRect);
  258.     scratchRect = drawIt->portRect;
  259.     scratchRect.top = scratchRect.bottom - 15;
  260.     scratchRect.left = scratchRect.right - 15;
  261.     tempRgn = NewRgn();
  262.     GetClip(tempRgn);
  263.     ClipRect(&scratchRect);
  264.     DrawGrowIcon(drawIt);
  265.     SetClip(tempRgn);
  266.     DrawControls(drawIt);
  267.     DisposeRgn(tempRgn);
  268.  
  269.     
  270.     EndUpdate(drawIt);
  271. }
  272.  
  273. /* my menu action taker.  It returns a Boolean which I usually ignore, but it */
  274. /* mught be handy someday */
  275. /* I usually use it in an application to determine if a keystroke was accepted */
  276. /* by a menu or whether it should be passed along to any other key acceptors */
  277. Boolean DoSelected(long val)
  278. {
  279.     short loval, hival;
  280.     Boolean returnVal = false;
  281.     loval = LoWord(val);
  282.     hival = HiWord(val);
  283.     
  284.     switch (hival) {                                        /* switch off the menu number selected */
  285.         case kAppleMenu:                                    /* Apple menu */
  286.             if (loval != 1) {                               /* if this was not About, it's a DA */
  287.                 DoDaCall(GetMenuHandle(kAppleMenu), loval);
  288.             } else {
  289.                 Alert(kAboutBox, nil);                      /* do about box */
  290.             }
  291.             returnVal = true;
  292.             break;
  293.         case kFileMenu:                                     /* File menu */
  294.             switch (loval) {
  295.                 case kQuitItem:
  296.                     gQuit = true;                           /* only  item */
  297.                     returnVal = true;
  298.                     break;
  299.                 default:
  300.                     break;
  301.             }
  302.             break;
  303.         case kEditMenu:
  304.             /* edit menu junk */
  305.             /* don't care */
  306.             switch(loval){
  307.             default:
  308.             break;}
  309.             break;
  310.         case kToolsMenu:
  311.             /* add all your test stuff here */
  312.             switch(loval){
  313.             default:
  314.             break;}
  315.  
  316.             break;
  317.         case kHMHelpMenuID:                                 /* Defined in Balloons.h */
  318.             /* I only care about this item.  If anything else is returned here, I don't know what */
  319.             /* it is, so I leave it alone.  Remember, the Help Manager chapter says that */
  320.             /* Apple reserves the right to add and change things in the Help menu */
  321.             if (loval == gHelpItem)
  322.                 SampleHelpDialog();
  323.             break;
  324.             
  325.     }
  326.     HiliteMenu(0);
  327.     return(returnVal);
  328. }
  329.  
  330.  
  331. void DoDocumentClick(WindowPtr theWindow)
  332. {Point thePoint;
  333. ControlHandle theControl;
  334. GetMouse(&thePoint);
  335. if(FindControl(thePoint, theWindow, &theControl)){
  336.     /* ••• NOTE! */
  337.     /* You MUST pass  '(ProcPtr) -1' to TrackControl to have the */
  338.     /* popupCDEF menus automatically popped and tracked for you! */
  339.     if(TrackControl(theControl, thePoint,(ControlActionUPP) -1)){
  340.     Str255 myString;
  341.     MenuHandle selectedMenu;
  342.     Rect clearIt;
  343.     SetRect(&clearIt,0,0,theWindow->portRect.right,20);
  344.     EraseRect(&clearIt);
  345.     /* if you selected something, I'll tell you about it */
  346.     
  347.     MoveTo(5,16);
  348.     GetIndString(&myString,kGeneralStrings,kSayLastItem);
  349.     DrawString(myString);
  350.     selectedMenu = GetPopUpMenuHandle(theControl);
  351.     GetMenuItemText(selectedMenu, GetControlValue(theControl),myString);
  352.     DrawString(myString);
  353.     }
  354.     }
  355.  
  356. }
  357.  
  358.  
  359. /* InitAEStuff installs my appleevent handlers */
  360. void InitAEStuff(void)
  361. {    
  362.     OSErr aevtErr = noErr;
  363.     long aLong = 0;
  364.     Boolean gHasAppleEvents = false;
  365.     /* Check this machine for AppleEvents.  If they are not here (ie not 7.0)
  366.     *   then we exit */
  367.     gHasAppleEvents = (Gestalt(gestaltAppleEventsAttr, &aLong) == noErr);
  368.     /* The following series of calls installs all our AppleEvent Handlers.
  369.     *   These handlers are added to the application event handler list that 
  370.     *   the AppleEvent manager maintains.  So, whenever an AppleEvent happens
  371.     *   and we call AEProcessEvent, the AppleEvent manager will check our
  372.     *   list of handlers and dispatch to it if there is one.
  373.     */
  374.     if (gHasAppleEvents) {
  375.          aevtErr = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, 
  376.              NewAEEventHandlerProc(AEOpenHandler),0, false);
  377.              if (aevtErr)  ExitToShell();
  378.  
  379.          aevtErr = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, 
  380.              NewAEEventHandlerProc(AEOpenDocHandler),0, false);
  381.              if (aevtErr)  ExitToShell();
  382.  
  383.          aevtErr = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, 
  384.              NewAEEventHandlerProc(AEQuitHandler), 0, false);
  385.              if (aevtErr)  ExitToShell();
  386.  
  387.          aevtErr = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, 
  388.              NewAEEventHandlerProc(AEPrintHandler),0, false);
  389.              if (aevtErr)  ExitToShell();
  390.          
  391.        } 
  392.     else ExitToShell();
  393.     
  394. }
  395. /* end InitAEStuff */
  396.  
  397.  
  398. /* I'm not doing error handling in this sample for clarities sake, you should. Hah, */
  399. /* easy for me to say, huh? */
  400. void DoHighLevel(EventRecord *AERecord)
  401. {OSErr myErr;
  402.     myErr=AEProcessAppleEvent(AERecord);
  403.     
  404. }
  405.  
  406. /* end DoHighLevel */
  407.  
  408. /* This is the standard Open Application event.  */
  409. pascal OSErr AEOpenHandler(AppleEvent *messagein, AppleEvent *reply, long refIn)
  410. {WindowPtr myWindow; 
  411.  
  412. #pragma unused (messagein,reply,refIn)
  413.     /* we of course don't do anything here in this simple app */
  414.     /* except open our window */
  415.     myWindow = AddNewWindow(kDocWindowResID);
  416.     
  417.     return(noErr);
  418. }
  419.  
  420. /* end AEOpenHandler */
  421.  
  422. /* Open Doc, opens our documents.  Remember, this can happen at application start AND */
  423. /* anytime else.  If your app is up and running and the user goes to the desktop, hilites one */
  424. /* of your files, and double-clicks or selects Open from the finder File menu this event */
  425. /* handler will get called. Which means you don't do any initialization of globals here, or */
  426. /* anything else except open then doc.  */
  427. /* SO-- Do NOT assume that you are at app start time in this */
  428. /* routine, or bad things will surely happen to you. */
  429.  
  430. pascal OSErr AEOpenDocHandler(AppleEvent *messagein, AppleEvent *reply, long refIn)
  431. {
  432. #pragma unused (messagein,refIn,reply)
  433.     /* we of course don't do anything here */
  434.     return(errAEEventNotHandled);                           /* we have no docs, so no odoc events should come to us */
  435. }
  436.  
  437. pascal OSErr AEPrintHandler(AppleEvent *messagein, AppleEvent *reply, long refIn)
  438. {                                                           /* no printing handler in yet, so we'll ignore this */
  439.     /* the operation is functionally identical to the ODOC event, with the additon */
  440.     /* of calling your print routine.  */
  441. #pragma unused (messagein,refIn,reply)
  442.     /* we of course don't do anything here */
  443.     return(errAEEventNotHandled);                           /* we have no docs, so no pdoc events should come to us */
  444. }
  445.  
  446. /* Standard Quit event handler, to handle a Quit event from the Finder, for example.  */
  447. /* ••••• DO NOT CALL EXITTOSHELL HERE ••••• or you will never have a happy life.  */
  448. /* OK, it's a few months after I wrote that comment, and I've seen a lot of code */
  449. /* come through DTS that calls ExitToShell from quit handlers.  Let me explain... */
  450. /* When an AppleEvent Handler is called (like this quit handler) you are ALMOST */
  451. /* 100% in your application world.  A5 is right, you can call any toolbox function, */
  452. /* you can call your own routines, everything _seems_ like you are in complete  */
  453. /* control.  Well, almost but not quite.  The routine has been dispatch to from the */
  454. /* AppleEvent Manager's space, so you _must_ return to that at some point! */
  455. /* Which is why you can't call ETS from here.  When you call ExitToShell from an */
  456. /* AE Handler, the most likely thing that happens is the FInder quits, and your  */
  457. /* application keeps running.  Which ain't what you want, y'know? */
  458. /* so, DON'T CALL EXITTOSHELL FROM AN APPLEEVENT HANDLER!!!!!!!!!!!!!! */
  459. pascal OSErr AEQuitHandler(AppleEvent *messagein, AppleEvent *reply, long refIn)
  460. {
  461. #pragma unused (messagein,refIn,reply)
  462.     gQuit = true;
  463.     return(noErr);
  464. }
  465.  
  466.  
  467.  
  468. /* This is my sample help dialog.  Does not do anything, expand as you need */
  469. void SampleHelpDialog(void)
  470. {
  471.     DialogPtr tdial = GetNewDialog(kSampHelp, nil, (WindowPtr)-1);
  472.     short itemhit = 0;
  473.     while (itemhit != 1) {
  474.         ModalDialog(nil, &itemhit);
  475.     }
  476.     DisposeDialog(tdial);
  477. }
  478.  
  479.  
  480. #pragma segment Initialize
  481. void InitalizeApp(void)
  482. {
  483.     Handle myMenu;
  484.     MenuHandle helpHandle,appleMenuHandle;
  485.     StringHandle helpString;
  486.     short count;
  487.     long vers;
  488.     MaxApplZone();
  489.     InitGraf(&qd.thePort);
  490.     InitFonts();
  491.     InitWindows();
  492.     InitMenus();
  493.     TEInit();
  494.     InitDialogs(nil);
  495.     InitCursor();
  496.     /* Check system version */
  497.     Gestalt(gestaltSystemVersion, &vers);
  498.     vers = (vers >> 8) & 0xf;                               /* shift result over and mask out major version number */
  499.     if (vers < 7) {
  500.         StopAlert(kBadSystem, nil);
  501.         ExitToShell();
  502.     }
  503.     InitAEStuff();
  504.     /* set up my menu junk */
  505.     myMenu = GetNewMBar(kMBarID);
  506.     SetMenuBar(myMenu);
  507.     appleMenuHandle = GetMenuHandle(kAppleMenu);
  508.     AppendResMenu(appleMenuHandle, 'DRVR');
  509.  
  510.     /* now install my Help menu item in the Help Manager's menu */
  511.     HMGetHelpMenuHandle(&helpHandle);                       /* Get the Hlpe menu handle */
  512.     count = CountMItems(helpHandle);                        /* How many items are there? */
  513.     helpString = GetString(kHelpString);                    /* get my help string */
  514.     DetachResource(helpString);                             /* detach it */
  515.     HNoPurge(helpString);
  516.     MoveHHi((Handle)helpString);
  517.     HLock((Handle)helpString);
  518.     InsertMenuItem(helpHandle, (Ptr)*helpString, count + 1);       /* insert my item in the Help menu */
  519.     gHelpItem = CountMItems(helpHandle);                    /* The number of the item */
  520.     
  521.        
  522.     DrawMenuBar();
  523.     GetCurrentProcess(&gOurSN);                             /* Get our process serial number for later use, if needed */
  524.     
  525. }
  526.  
  527.  
  528. #pragma segment Main
  529. WindowPtr AddNewWindow(short theID)
  530. {
  531.     windowCHandle setControls;
  532.     WindowPtr tempWP;
  533.     short cnt = 0;
  534.     tempWP = GetNewWindow(theID, 0, (WindowPtr)-1);        /* get a new window */
  535.     SetPort(tempWP);
  536.     ((WindowPeek)tempWP)->windowKind = kMyDocumentWindow;     /* mark it as my document window */
  537.     setControls = (windowCHandle)NewHandleClear(sizeof(windowControl));       /* add our control structure to it */
  538.     SetWRefCon(tempWP,(long)setControls);    /* stop stuffing refCon directly <ckh 1.0.3> */
  539.     HLock((Handle)setControls);                             /* lock it down while we fill it*/
  540.     
  541.     /* add pointers to our procedures for drawing, saving, and closing */
  542.     /* This way, all I need is one dispatch point for drawing, closing */
  543.     /* or whatever, I don't have to case off the window kind to go to the  */
  544.     /* correct routine.  Kinda like object-oriented programming, but I won't */
  545.     /* admit that. */
  546.     
  547.     (*setControls)->drawMe = (ProcPtr)DrawMain;
  548.     (*setControls)->clickMe = (ProcPtr)DoDocumentClick;
  549.     (*setControls)->sizeMe = (ProcPtr)SizeMain;
  550.     (*setControls)->generalData = NewHandle(0);
  551.         GetNewControl(128,tempWP);
  552.         GetNewControl(129,tempWP);
  553.         GetNewControl(130,tempWP);
  554.         GetNewControl(131,tempWP);
  555.  
  556. return(tempWP);
  557. }
  558.  
  559. void SizeMain(WindowPtr theWindow)
  560. {
  561. WindowPtr tempWP;
  562. GetPort(&tempWP);
  563. InvalRect(&theWindow->portRect);
  564. SetPort(tempWP);
  565. }
  566.  
  567. void NilProc(void)
  568. {
  569.  
  570. }
  571.  
  572.  
  573.  
  574. /* Since we can't call GetMenuHandle to access the menu handle, we have to  */
  575. /* look at the data stored in the control record */
  576. MenuHandle GetPopUpMenuHandle(ControlHandle thisControl)
  577. {
  578. popupPrivateDataHdl theMenuData = (popupPrivateDataHdl)(*thisControl)->contrlData;
  579. return((*theMenuData)->mHandle);
  580. }
  581.  
  582.  
  583.  
  584.